{layout name="common/base" }
<nav class="breadcrumb">
	<i class="Hui-iconfont">&#xe67f;</i> 首页
	<span class="c-gray en">&gt;</span>商品管理
	<span class="c-gray en">&gt;</span> 商品列表
	<a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" >
		<i class="Hui-iconfont">&#xe68f;</i>
	</a>
</nav>
<div class="page-container">
	<div class="cl pd-5 bg-1 bk-gray mt-20"> <span class="l">
		<a class="btn btn-primary radius" onclick="add_edit('添加商品','{:url(\'product/add\')}','800')" href="javascript:;"><i class="Hui-iconfont">&#xe600;</i> 添加商品</a>
	</span> <!--<span class="r">共有数据：<strong>54</strong> 条</span> --></div>
	<div class="mt-20">
		<table class="table table-border table-bordered table-bg table-hover table-sort">
			<thead>
			<tr class="text-c">
				<th width="50">ID</th>
				<th width="600">名称</th>
				<th width="100">封面图</th>
				<th width="100">市场价</th>
				<th width="100">本店价</th>
				<!-- <th width="150">分类</th> -->
				<th width="100">热卖</th>
				<th width="100">新品</th>
				<th width="100">状态</th>
				<th width="100">库存</th>
				<th width="100">排序</th>
				<th width="200">添加时间</th>
				<th width="100">操作</th>
			</tr>
			</thead>
			<tbody>
			{volist name="data" id="vo"}
			<tr class="text-c">
				<td style="text-align:center;vertical-align:middle;">{$vo.id}</td>
				<td style="text-align:center;vertical-align:middle;">{$vo.name}</td>
				<td style="text-align:center;vertical-align:middle;"><img width="50" height="50" src="{$vo.thumb}"></td>
				<td style="text-align:center;vertical-align:middle;">{$vo.market_price}</td>
				<td style="text-align:center;vertical-align:middle;">{$vo.shop_price}</td>
				<td style="text-align:center;vertical-align:middle;"><?php echo $vo['is_hot']==1?'是':'否'; ?></td>
				<td style="text-align:center;vertical-align:middle;"><?php echo $vo['is_new']==1?'是':'否'; ?></td>
				<?php if($vo['status'] == 1): ?>
				<td onClick="status(this,'{$vo.id}')" style="color: #00ff00;">上架</td>
				<?php else: ?>
				<td onClick="status(this,'{$vo.id}')" style="color: #ff0000;">下架</td>
				<?php endif; ?>
				<td style="text-align:center;vertical-align:middle;">{$vo.gn}</td>
				<td style="text-align:center;vertical-align:middle;">{$vo.sort}</td>
				<td style="text-align:center;vertical-align:middle;">{$vo.create_time}</td>
				<td class="td-manage">
					<a style="text-decoration:none" class="ml-5"
					   onClick="add_edit('编辑','{:url(\'product/edit\',array(\'id\'=>$vo.id))}','10001')" href="javascript:;" title="修改">
						<i class="Hui-iconfont">&#xe6df;</i>
					</a>
					<a style="text-decoration:none" class="ml-5" onClick="del(this,'{$vo.id}')" href="javascript:;" title="删除"><i class="Hui-iconfont">&#xe6e2;</i></a>
				</td>
			</tr>
			{/volist}

			</tbody>
		</table>
		{:pagination($data)}
	</div>
</div>


<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="__PUBLIC__/lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="__PUBLIC__/lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/lib/laypage/1.2/laypage.js"></script>

<script type="text/javascript" src="__PUBLIC__/lib/lightbox2/2.8.1/js/lightbox.min.js"></script>
<script type="text/javascript">
    function status(obj,id){
        $.ajax({
            type : "GET",
            url : "/admin/product/ajaxUpdateStatus/id/"+id,
            success : function(data) {
                console.log(data);
                if(data == 1){
                    $(obj).css("color","#00ff00");
                    //$(obj).style.color="#00ff00";
                    $(obj).html('上架');
                    layer.msg("上架",{icon: 1,time:1000});
                }else{
                    //$(obj).style.color="#ff0000";
                    $(obj).css("color","#ff0000");
                    $(obj).html('下架');
                    layer.msg("下架",{icon: 2,time:1000});
                }
            }
        });
    }
    function add_edit(title,url){
        var index = layer.open({
            type: 2,
            title: title,
            content: url
        });
        layer.full(index);
    }
    function del(obj,id){
        layer.confirm('确认要删除吗？',function(index){
            $.ajax({
                type: 'POST',
                url: "/admin/banner/del/id/"+id,
                dataType: 'json',
                success: function(data){
                    if(data == 0){
                        $(obj).parents("tr").remove();
                        layer.msg('已删除!',{icon:1,time:1000});
                    }else {
                        layer.msg('删除失败!',{icon:1,time:1000});
                    }

                },
                error:function(data) {
                    //console.log(data.msg);
                },
            });
        });
    }

</script>